package pt.xpand.xinx.players;

import java.util.Random;

import pt.xpand.xinx.entities.Board;
import pt.xpand.xinx.entities.Position;
import pt.xpand.xinx.entities.interfaces.IPlayer;

/**
 * @author Kiko
 *
 * Implementation of the Blue Player
 *
 */
public class PlayerAlwaysValid implements IPlayer {
	
	private String name;
	//For use until we don't have grahics
	private String symbol;
	
	/**
	 * Constructor for PlayerBlue
	 * 
	 * @param name
	 * @param color
	 */
	public PlayerAlwaysValid(String name,  String symbol) {
		this.setName(name);
		this.setSymbol(symbol);
	}

	/* (non-Javadoc)
	 * @see pt.xpand.xinx.entities.IPlayer#setName(java.lang.String)
	 */
	public void setName(String name) {
		this.name = name;
	}

	/* (non-Javadoc)
	 * @see pt.xpand.xinx.entities.IPlayer#getName()
	 */
	public String getName() {
		return name;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	public String getSymbol() {
		return symbol;
	}
	
	/* (non-Javadoc)
	 * @see pt.xpand.xinx.entities.IPlayer#play()
	 */
	public Position play(Board board) {
		Random generator = new Random();
		Position position = null; 
		
		while(position == null || !board.isValid(position)) {
			position = new Position(generator.nextInt(board.getSize()), generator.nextInt(board.getSize()));
		}
		
		return position;
	}

}
